//
//  NamespaceItem.swift
//  cabbage_swift
//
//  Created by dfsx6 on 2021/10/8.
//

import Foundation
import UIKit

//MARK:-
class NamespaceItem: NSObject {
    
    fileprivate var itemSize: CGSize {
        return CGSize.init(width: UIScreen.main.bounds.width, height: 50)
    }
}

//MARK:-
extension NamespaceItem: BaseCollectionSectionProtocol {
    func registerForCollectionViewCell(_ collectionView: UICollectionView) {
        collectionView.exRegister(cell: WaterfallCollectionViewCell.self)
    }
    
    func numberOfItemsInSection(_ collectionView: UICollectionView) -> Int {
        return 1
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        guard let cell = collectionView.exDequeueReusableCell(for: indexPath, cellType: WaterfallCollectionViewCell.self) else {
            return UICollectionViewCell.init()
        }
        cell.bgViewWidth.constant = itemSize.width
        //cell.bgViewHeight.constant = itemSize.height
        cell.titleLabel.text = "命名空间"
        return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let targetVC = NamespaceViewController.init()
        exTopVC?.navigationController?.pushViewController(targetVC, animated: true)
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return itemSize
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 20
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
        return UIEdgeInsets.init(top: 20, left: 0, bottom: 20, right: 0)
    }
}
